package TeacherEvaluation.com.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import TeacherEvaluation.com.dao.pollDao;
import TeacherEvaluation.com.entity.Poll;

@Service
public class pollService {
	@Autowired
	pollDao pollDao;
	
	public int selectPoByAsMa(Poll poll,String type) {
		Poll poll2 = pollDao.selectPoByAsMa(poll);
		if (poll2!=null) {
			if (type=="A") {
				pollDao.updateA(poll);
			}
			if (type=="B") {
				pollDao.updateB(poll);
			}
			if (type=="C") {
				pollDao.updateC(poll);
			}
			if (type=="D") {
				pollDao.updateD(poll);
			}
		}else {
			if (type=="A") {
				pollDao.insertPollA(poll);
			}
			if (type=="B") {
				pollDao.insertPollB(poll);
			}
			if (type=="C") {
				pollDao.insertPollC(poll);
			}
			if (type=="D") {
				pollDao.insertPollD(poll);
			}
		}
		return 1;
	};
	
	public List<Poll> selectPoByAs(int as_id){
		return pollDao.selectPoByAs(as_id);
	}
	
}
